package com.wfm.service.deploy;

import com.wfm.service.domain.UatDeploy;
import com.wfm.service.domain.UatDeployWithBLOBs;
import com.wfm.service.mapper.UatDeployMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 假设这个是你的DAO存储。当然还要这个类让spring管理，当然你不用需要存储，也不需要这个类。
 *
 * @author Jiaju Zhuang
 **/
@Component
public class DemoDAO {

    @Autowired
    private UatDeployMapper uatDeployMapper;

    public void save(List<DemoData> list) {
        // 如果是mybatis,尽量别直接调用多次insert,自己写一个mapper里面新增一个方法batchInsert,所有数据一次性插入

        for (int i = 0; i < list.size(); i++) {
            DemoData demoData = list.get(i);
            UatDeployWithBLOBs uatDeploy = new UatDeployWithBLOBs();
            BeanUtils.copyProperties(demoData,uatDeploy);
            uatDeployMapper.insertSelective(uatDeploy);
        }
    }
}